package com.titaniume.java;

import java.util.Arrays;

/**
 * @program: JavaSenior
 * @description: 使用enum关键字定便宜枚举类
 *
 * 说明定义的枚举类默认继承 class java.lang.Enum
 *
 * @author: renfei.huang
 * @create: 2021-10-10 23:42
 */
public class SeasonTest1 {

    public static void main(String[] args) {
        Season1 sumer = Season1.SUMER;
        System.out.println(sumer);

        //toString()
        System.out.println(Season1.class.getSuperclass());


        //values()
        Season1[] values = Season1.values();
        for (int i = 0; i < values.length ; i++) {
            System.out.println(values[i]);
            values[i].show();
        }
//        System.out.println(Arrays.toString(values));


        Thread.State[] values1 = Thread.State.values();
        System.out.println(Arrays.toString(values1));


        //valueOf(String ObjName)
        //根据提供的objName返回枚举类中对象的是objName的对象
        //如果没有objName的枚举类对象则 抛出异常: IllegalArgumentException
        Season1 winter = Season1.valueOf("SPRING");
        System.out.println(winter);

        sumer.show();

    }
}

interface Info{
    void show();
}

//使用enum关键字
enum Season1 implements Info {


    //1.提供当前枚举类的对象，多个对象之间用","隔开 ，末尾对象";"
    SPRING("春天", "春暖花开"){
        @Override
        public void show() {
            System.out.println("春天来了");
        }
    },
    SUMER("夏天", "夏日炎炎"){
        @Override
        public void show() {
            System.out.println("夏天来了");
        }
    },
    AUTUMU("秋天", "秋高气爽"){
        @Override
        public void show() {
            System.out.println("秋天来了");
        }
    },
    WINTER("冬天", "冰天雪地"){
        @Override
        public void show() {
            System.out.println("冬天来了");
        }
    };


    //1.声明Season对象的属性: private final 修饰
    private final String seasonName;
    private final String seasonDesc;

    //2.私有化构造器
    private Season1(String seasonName, String seasonDesc) {
        this.seasonName = seasonName;
        this.seasonDesc = seasonDesc;
    }


    //4.其他诉求 ： 获取枚举类对象的属性
    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }

//    @Override
//    public void show() {
//        System.out.println("这是一个季节");
//    }

    //不重写默认使用Enum的toString()
//    @Override
//    public String toString() {
//        return "Season{" +
//                "seasonName='" + seasonName + '\'' +
//                ", seasonDesc='" + seasonDesc + '\'' +
//                '}';
//    }


}
